//
//  XFlowerCell.swift
//  WeiBoReDo
//
//  Created by 放学跟鸽走 on 2017/4/18.
//  Copyright © 2017年 放学跟鸽走. All rights reserved.
//

import UIKit

class XFlowerCell: UICollectionViewCell {
    /// 图片logo
    lazy var imageView = UIImageView()
    
    var model:XFlowerViewModel?{
        didSet{
            imageView.cz_setImage(urlString: model?.flower?.goodsLogo, placeholderImage: nil)
        }
    }
    override init(frame: CGRect) {
        super.init(frame: frame)
        setupUI()
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
//        fatalError("init(coder:) has not been implemented")
        setupUI()
    }
}
extension XFlowerCell{
    ///设置UI
    fileprivate func setupUI(){
        //离屏渲染
        self.layer.drawsAsynchronously = true
        //栅格化
        self.layer.shouldRasterize = true
        //使用栅格化必须指定分辨率
        self.layer.rasterizationScale = UIScreen.main.scale

        
        addSubview(imageView)
        
        for iv in subviews{
            iv.translatesAutoresizingMaskIntoConstraints = false
        }
        setupViewInCell()
    }
    func setupViewInCell(){
        let itemW = (UIScreen.cz_screenWidth()-15)/2
        let itemH = (UIScreen.cz_screenWidth()-15)/2
        imageView.snp.makeConstraints { (make) in
            make.left.top.equalTo(self)
            make.size.equalTo(CGSize(width: itemW, height: itemH))
        }

    }
}
